From: kaf24@firebug.cl.cam.ac.uk Date: Thu, 25 May 2006 13:15:49 +0000 (+0100) Subject: Separate xenbusstate enumeration from typedef. Avoid using the typedef X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~16025^2~21 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=f7ea0be1ff0c8884d2229813cb00080cc6f268df;p=xen.git Separate xenbusstate enumeration from typedef. Avoid using the typedef in Linux coe as it is consider bad coding style. Signed-off-by: Keir Fraser --- diff --git a/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c b/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c index 0e418299eb..ff356f1342 100644 --- a/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c +++ b/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c @@ -329,7 +329,7 @@ out: * Callback received when the backend's state changes. */ static void backend_changed(struct xenbus_device *dev, - XenbusState backend_state) + enum xenbus_state backend_state) { struct tpm_private *tp = dev->data; DPRINTK("\n"); diff --git a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c index 25fd667f5a..3e305f743a 100644 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c @@ -247,7 +247,7 @@ static void backend_changed(struct xenbus_watch *watch, * Callback received when the frontend's state changes. */ static void frontend_changed(struct xenbus_device *dev, - XenbusState frontend_state) + enum xenbus_state frontend_state) { struct backend_info *be = dev->data; int err; diff --git a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c index f8e45efa47..a61b0765d4 100644 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c @@ -247,7 +247,7 @@ fail: * Callback received when the backend's state changes. */ static void backend_changed(struct xenbus_device *dev, - XenbusState backend_state) + enum xenbus_state backend_state) { struct blkfront_info *info = dev->data; struct block_device *bd; @@ -434,7 +434,7 @@ int blkif_release(struct inode *inode, struct file *filep) have ignored this request initially, as the device was still mounted. */ struct xenbus_device * dev = info->xbdev; - XenbusState state = xenbus_read_driver_state(dev->otherend); + enum xenbus_state state = xenbus_read_driver_state(dev->otherend); if (state == XenbusStateClosing) blkfront_closing(dev); diff --git a/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c b/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c index dd2574aa68..60d570c69c 100644 --- a/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c +++ b/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c @@ -37,7 +37,7 @@ struct backend_info struct xenbus_device *dev; netif_t *netif; struct xenbus_watch backend_watch; - XenbusState frontend_state; + enum xenbus_state frontend_state; }; @@ -191,7 +191,7 @@ static void backend_changed(struct xenbus_watch *watch, * Callback received when the frontend's state changes. */ static void frontend_changed(struct xenbus_device *dev, - XenbusState frontend_state) + enum xenbus_state frontend_state) { struct backend_info *be = dev->data; diff --git a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c index 431841523d..02f241c0b7 100644 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c @@ -384,7 +384,7 @@ static int setup_device(struct xenbus_device *dev, struct netfront_info *info) * Callback received when the backend's state changes. */ static void backend_changed(struct xenbus_device *dev, - XenbusState backend_state) + enum xenbus_state backend_state) { DPRINTK("\n"); diff --git a/linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c b/linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c index 2d49e3a9e3..672a2f7fbc 100644 --- a/linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c +++ b/linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c @@ -166,7 +166,7 @@ static int pciback_attach(struct pciback_device *pdev) } static void pciback_frontend_changed(struct xenbus_device *xdev, - XenbusState fe_state) + enum xenbus_state fe_state) { struct pciback_device *pdev = xdev->data; diff --git a/linux-2.6-xen-sparse/drivers/xen/pcifront/xenbus.c b/linux-2.6-xen-sparse/drivers/xen/pcifront/xenbus.c index ee154ba360..dbd672431b 100644 --- a/linux-2.6-xen-sparse/drivers/xen/pcifront/xenbus.c +++ b/linux-2.6-xen-sparse/drivers/xen/pcifront/xenbus.c @@ -196,7 +196,7 @@ static int pcifront_try_connect(struct pcifront_device *pdev) static int pcifront_try_disconnect(struct pcifront_device *pdev) { int err = 0; - XenbusState prev_state; + enum xenbus_state prev_state; spin_lock(&pdev->dev_lock); @@ -214,7 +214,7 @@ static int pcifront_try_disconnect(struct pcifront_device *pdev) } static void pcifront_backend_changed(struct xenbus_device *xdev, - XenbusState be_state) + enum xenbus_state be_state) { struct pcifront_device *pdev = xdev->data; diff --git a/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c b/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c index ffc8945ece..b5817ff663 100644 --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c @@ -34,7 +34,7 @@ struct backend_info /* watch front end for changes */ struct xenbus_watch backend_watch; - XenbusState frontend_state; + enum xenbus_state frontend_state; }; static void maybe_connect(struct backend_info *be); @@ -43,7 +43,7 @@ static int connect_ring(struct backend_info *be); static void backend_changed(struct xenbus_watch *watch, const char **vec, unsigned int len); static void frontend_changed(struct xenbus_device *dev, - XenbusState frontend_state); + enum xenbus_state frontend_state); static int tpmback_remove(struct xenbus_device *dev) { @@ -129,7 +129,7 @@ static void backend_changed(struct xenbus_watch *watch, static void frontend_changed(struct xenbus_device *dev, - XenbusState frontend_state) + enum xenbus_state frontend_state) { struct backend_info *be = dev->data; int err; diff --git a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c index 973407d208..fc8228390a 100644 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c @@ -84,7 +84,7 @@ int xenbus_watch_path2(struct xenbus_device *dev, const char *path, EXPORT_SYMBOL_GPL(xenbus_watch_path2); -int xenbus_switch_state(struct xenbus_device *dev, XenbusState state) +int xenbus_switch_state(struct xenbus_device *dev, enum xenbus_state state) { /* We check whether the state is currently set to the given value, and if not, then the state is set. We don't want to unconditionally @@ -269,9 +269,9 @@ int xenbus_free_evtchn(struct xenbus_device *dev, int port) } -XenbusState xenbus_read_driver_state(const char *path) +enum xenbus_state xenbus_read_driver_state(const char *path) { - XenbusState result; + enum xenbus_state result; int err = xenbus_gather(XBT_NULL, path, "state", "%d", &result, NULL); if (err) result = XenbusStateClosed; diff --git a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c index f410395d19..e54d981165 100644 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c @@ -284,7 +284,7 @@ static void otherend_changed(struct xenbus_watch *watch, struct xenbus_device *dev = container_of(watch, struct xenbus_device, otherend_watch); struct xenbus_driver *drv = to_xenbus_driver(dev->dev.driver); - XenbusState state; + enum xenbus_state state; /* Protect us against watches firing on old details when the otherend details change, say immediately after a resume. */ @@ -539,7 +539,7 @@ static int xenbus_probe_node(struct xen_bus_type *bus, size_t stringlen; char *tmpstring; - XenbusState state = xenbus_read_driver_state(nodename); + enum xenbus_state state = xenbus_read_driver_state(nodename); if (state != XenbusStateInitialising) { /* Device is not new, so ignore it. This can happen if a diff --git a/linux-2.6-xen-sparse/include/xen/xenbus.h b/linux-2.6-xen-sparse/include/xen/xenbus.h index 717b475664..a944dfdf4e 100644 --- a/linux-2.6-xen-sparse/include/xen/xenbus.h +++ b/linux-2.6-xen-sparse/include/xen/xenbus.h @@ -75,7 +75,7 @@ struct xenbus_device { int otherend_id; struct xenbus_watch otherend_watch; struct device dev; - XenbusState state; + enum xenbus_state state; void *data; }; @@ -98,7 +98,7 @@ struct xenbus_driver { int (*probe)(struct xenbus_device *dev, const struct xenbus_device_id *id); void (*otherend_changed)(struct xenbus_device *dev, - XenbusState backend_state); + enum xenbus_state backend_state); int (*remove)(struct xenbus_device *dev); int (*suspend)(struct xenbus_device *dev); int (*resume)(struct xenbus_device *dev); @@ -207,7 +207,7 @@ int xenbus_watch_path2(struct xenbus_device *dev, const char *path, * Return 0 on success, or -errno on error. On error, the device will switch * to XenbusStateClosing, and the error will be saved in the store. */ -int xenbus_switch_state(struct xenbus_device *dev, XenbusState new_state); +int xenbus_switch_state(struct xenbus_device *dev, enum xenbus_state new_state); /** @@ -273,7 +273,7 @@ int xenbus_free_evtchn(struct xenbus_device *dev, int port); * Return the state of the driver rooted at the given store path, or * XenbusStateClosed if no state can be read. */ -XenbusState xenbus_read_driver_state(const char *path); +enum xenbus_state xenbus_read_driver_state(const char *path); /*** diff --git a/xen/include/public/io/xenbus.h b/xen/include/public/io/xenbus.h index 472079c12b..1c752dfaeb 100644 --- a/xen/include/public/io/xenbus.h +++ b/xen/include/public/io/xenbus.h @@ -9,34 +9,37 @@ #ifndef _XEN_PUBLIC_IO_XENBUS_H #define _XEN_PUBLIC_IO_XENBUS_H -/* The state of either end of the Xenbus, i.e. the current communication - status of initialisation across the bus. States here imply nothing about - the state of the connection between the driver and the kernel's device - layers. */ -typedef enum -{ - XenbusStateUnknown = 0, - XenbusStateInitialising = 1, - XenbusStateInitWait = 2, /* Finished early initialisation, but waiting - for information from the peer or hotplug - scripts. */ - XenbusStateInitialised = 3, /* Initialised and waiting for a connection - from the peer. */ - XenbusStateConnected = 4, - XenbusStateClosing = 5, /* The device is being closed due to an error - or an unplug event. */ - XenbusStateClosed = 6 - -} XenbusState; - -#endif /* _XEN_PUBLIC_IO_XENBUS_H */ - /* - * Local variables: - * c-file-style: "linux" - * indent-tabs-mode: t - * c-indent-level: 8 - * c-basic-offset: 8 - * tab-width: 8 - * End: + * The state of either end of the Xenbus, i.e. the current communication + * status of initialisation across the bus. States here imply nothing about + * the state of the connection between the driver and the kernel's device + * layers. */ +enum xenbus_state { + XenbusStateUnknown = 0, + + XenbusStateInitialising = 1, + + /* + * InitWait: Finished early initialisation but waiting for information + * from the peer or hotplug scripts. + */ + XenbusStateInitWait = 2, + + /* + * Initialised: Waiting for a connection from the peer. + */ + XenbusStateInitialised = 3, + + XenbusStateConnected = 4, + + /* + * Closing: The device is being closed due to an error or an unplug event. + */ + XenbusStateClosing = 5, + + XenbusStateClosed = 6 +}; +typedef enum xenbus_state XenbusState; + +#endif /* _XEN_PUBLIC_IO_XENBUS_H */